﻿namespace LogicStudio.Framework.UI.Extensiones
{
    using Utilidades;
    using System.Windows;
    using System.Windows.Controls;

    /// <summary>
    /// Proporciana el atributo auxiliar TitleBinding a un objeto del tipo <see cref="Page"/>
    /// </summary>
    public static class PageHelper
    {
        #region Atributos

        public static readonly DependencyProperty TitleBindingProperty = DependencyProperty.RegisterAttached(
        TitleBinding,
        typeof(object),
        typeof(DataGridColumnHelper),
        new PropertyMetadata(null, TitleBindingPropertyChanged));

        #endregion

        #region Constantes

        private const string TitleBinding = "TitleBinding";

        #endregion

        #region Métodos Privados

        private static void TitleBindingPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var source = d as Page;

            if (source == null)
            {
                return;
            }

            source.Title = e.NewValue as string;
        }

        #endregion

        #region Métodos Públicos

        public static object GetTitleBinding(DependencyObject source)
        {
            return source.GetValue(TitleBindingProperty);
        }

        public static void SetTitleBinding(DependencyObject target, object value)
        {
            target.SetValue(TitleBindingProperty, value);
        }

        #endregion
    }
}